﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.MountAndBlade.View.Scripts.PopupSceneSequence
// Assembly: TaleWorlds.MountAndBlade.View, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 61152EB8-513B-4D4A-8AC0-0D1465C6CF6C
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\Modules\Native\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.View.dll

using TaleWorlds.Engine;

#nullable disable
namespace TaleWorlds.MountAndBlade.View.Scripts
{
  public class PopupSceneSequence : ScriptComponentBehavior
  {
    public float InitialActivationTime;
    public float PositiveActivationTime;
    public float NegativeActivationTime;
    protected AgentVisuals _agentVisuals;
    protected float _time;
    protected bool _triggered;
    protected int _state;

    public void InitializeWithAgentVisuals(AgentVisuals visuals)
    {
      this._agentVisuals = visuals;
      this._time = 0.0f;
      this._triggered = false;
      this._state = 0;
    }

    protected override void OnInit()
    {
      base.OnInit();
      this.SetScriptComponentToTick(this.GetTickRequirement());
    }

    public override ScriptComponentBehavior.TickRequirement GetTickRequirement()
    {
      return ScriptComponentBehavior.TickRequirement.Tick | base.GetTickRequirement();
    }

    protected override void OnTick(float dt)
    {
      this._time += dt;
      if (this._triggered)
        return;
      if (this._state == 0 && (double) this._time >= (double) this.InitialActivationTime)
      {
        this._triggered = true;
        this.OnInitialState();
      }
      if (this._state == 1 && (double) this._time >= (double) this.PositiveActivationTime)
      {
        this._triggered = true;
        this.OnPositiveState();
      }
      if (this._state != 2 || (double) this._time < (double) this.NegativeActivationTime)
        return;
      this._triggered = true;
      this.OnNegativeState();
    }

    public virtual void OnInitialState()
    {
    }

    public virtual void OnPositiveState()
    {
    }

    public virtual void OnNegativeState()
    {
    }

    public void SetInitialState()
    {
      this._triggered = false;
      this._state = 0;
      this._time = 0.0f;
    }

    public void SetPositiveState()
    {
      this._triggered = false;
      this._state = 1;
      this._time = 0.0f;
    }

    public void SetNegativeState()
    {
      this._triggered = false;
      this._state = 2;
      this._time = 0.0f;
    }
  }
}
